package cn.xbtop.fastdfs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/4/16 20:07
 */
@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private UploadService uploadService;

    @RequestMapping("/upload")
    public Map<String, Object> upload(MultipartFile mf) {
        System.out.println(mf.getOriginalFilename());

        Map<String, Object> map = new HashMap<>();
        String url = uploadService.uploadImage(mf);
        map.put("path", url);
        return map;
    }
}
